#include <bits/stdc++.h>
using namespace std;
const int N=1e5+50;
int n,m,Len,ne[N],vis[N],ans1,ans2,l[N],r[N],T,used[N];
double d[N],v[N],a[N],pos[N],V;
struct Line{
    int l,r;
};
vector<Line> L;
bool cmp(Line a,Line b){
    return a.r<b.r;
}
int main(){
    freopen("detect.in","r",stdin);freopen("detect.out","w",stdout);
    cin>>T;
    while(T--){
    ans2=0;memset(used,0,sizeof(used));
    L.clear();
    cin>>n>>m>>Len>>V;
    V+=1e-4;
    for(int i=1;i<=n;i++)cin>>d[i]>>v[i]>>a[i];
    for(int i=1;i<=m;i++)cin>>pos[i];
    pos[m+1]=1e9;
    sort(pos+1,pos+m+1,less<int>());
    for(int i=1;i<=n;i++){
        if(a[i]>0){
            double x=(V*V-v[i]*v[i])/(2*a[i])+d[i];
            if(v[i]>=V){
                int g=lower_bound(pos+1,pos+m+1,d[i])-pos;
                l[i]=pos[g];
                if(l[i]<1e9)L.push_back({l[i],(int)1e9});
            }
            else{
                int g=lower_bound(pos+1,pos+m+1,x)-pos;
                l[i]=pos[g];
                if(l[i]<1e9)L.push_back({l[i],(int)1e9});
            }
        }else if(a[i]==0){
            if(v[i]>=V){
                int g=lower_bound(pos+1,pos+m+1,d[i])-pos;
                l[i]=pos[g];
                if(l[i]<1e9)L.push_back({l[i],(int)1e9});
            }
        }else{
            if(v[i]<V)continue;
            double x=(V*V-v[i]*v[i])/(2*a[i])+d[i];
            int g1=lower_bound(pos+1,pos+m+1,d[i])-pos;l[i]=pos[g1];
            if(l[i]>=1e9)continue;
            int g2=upper_bound(pos+1,pos+m+1,x)-pos-1;r[i]=pos[g2];
            if(r[i]>=l[i])L.push_back({l[i],r[i]});
        }
    }

    ans1=L.size();
    sort(L.begin(),L.end(),cmp);
    for(int i=0;i<L.size();i++){
        if(used[i])continue;
        used[i]=1;ans2++;
        for(int j=i+1;j<L.size();j++){
            if(L[j].l<=L[i].r)used[j]=1;
        }
    }
    cout<<ans1<<" "<<m-ans2<<endl;
    }
    return 0;
}
